package Controlador.Componentes;

import Controlador.Controladores.FuenteTabla;
import Controlador.Interfaz.DataFuente;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.Observable;
import java.util.Observer;
import javax.swing.JCheckBox;

public class ChekBoxFuente  extends JCheckBox implements DataFuente, Observer{
    private String Campo="";
     private FuenteTabla tbl =null;
    
    @Override
    public boolean isLlave() {
        return false;
    }

    @Override
    public String getCampo() {
       return this.Campo;
    }

    @Override
    public String getTipoSeleccionado() {
        return "Boleano";
    }

    @Override
    public void update(Observable o, Object o1) {
         try {
            this.setSelected(this.getTbl().getRs().getBoolean(this.getCampo()));
            this.setText(Campo);
        } catch (SQLException ex) {
           
        }
    }


    public void setCampo(String Campo) {
        this.Campo = Campo;
    }

    public FuenteTabla getTbl() {
        return tbl;
    }

    public void setTbl(FuenteTabla tbl) {
        this.tbl = tbl;
         if(tbl!=null){
            this.getTbl().addObserver(this);
            this.getTbl().getLstObservadores().add(this);
        }
    }

    @Override
    public boolean validar() {
       return true;
    }

    @Override
    public boolean valor() {
       return this.isSelected();
    }

    @Override
    public void Limpiar() {
        this.setSelected(false);
    }

    @Override
    public boolean isAutoNumerico() {
       return false;
    }
    
}
